$(document).ready(function(){

        $('.ajax_state #StateCountryId').change(function(){

                var selected = $(this).val();

                ajax_loading_image('.ajax_loading_image');

                $.ajax({
                        type: "POST",
                        url: '/states/ajax_get_country_states',
                        data: "ajax=true&id="+selected,
                        success: function(msg){

                                $('.ajax_state_id').html(msg);
                                ajax_remove_loading_image('.ajax_loading_image');

                        }
                });

        });
});

// set a loading image
function ajax_loading_image(div) {
        $(div).html('<img src="/img/ajax-loading.gif" alt="Ajax Loading Image"/>');
}

// remove loading image
function ajax_remove_loading_image(div) {
        $(div).html('');
}

